import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store= new Vuex.Store({
  state: {
    userInfo: JSON.parse(localStorage.getItem("userInfo")) || {},
  },
  mutations: {
    //将用户信息存储到本地缓存中localStorage
    setUserInfo(state,userInfo){
      localStorage.setItem('userInfo',JSON.stringify(userInfo));
      state.userInfo = userInfo; //最后将userInfo 存入到vuex中store对象中
    }
  },
  actions: {
  },
  modules: {
  }
})
export default store
